\(\int \frac {\sec ^2(c+d x)}{a \cos (c+d x)+i a \sin (c+d x)} \, dx\) [157]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [B] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 31, antiderivative size = 31 \[ \int \frac {\sec ^2(c+d x)}{a \cos (c+d x)+i a \sin (c+d x)} \, dx=\frac {\text {arctanh}(\sin (c+d x))}{a d}-\frac {i \sec (c+d x)}{a d} \]

[Out]

arctanh(sin(d*x+c))/a/d-I*sec(d*x+c)/a/d

Rubi [A] (verified)

Time = 0.11 (sec) , antiderivative size = 31, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.161, Rules used = {3171, 3169, 3855, 2686, 8} \[ \int \frac {\sec ^2(c+d x)}{a \cos (c+d x)+i a \sin (c+d x)} \, dx=\frac {\text {arctanh}(\sin (c+d x))}{a d}-\frac {i \sec (c+d x)}{a d} \]

[In]

Int[Sec[c + d*x]^2/(a*Cos[c + d*x] + I*a*Sin[c + d*x]),x]

[Out]

ArcTanh[Sin[c + d*x]]/(a*d) - (I*Sec[c + d*x])/(a*d)

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 2686

Int[((a_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[a/f, Subst[
Int[(a*x)^(m - 1)*(-1 + x^2)^((n - 1)/2), x], x, Sec[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n -
1)/2] &&  !(IntegerQ[m/2] && LtQ[0, m, n + 1])

Rule 3169

Int[cos[(c_.) + (d_.)*(x_)]^(m_.)*(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(n_.), x_Sym
bol] :> Int[ExpandTrig[cos[c + d*x]^m*(a*cos[c + d*x] + b*sin[c + d*x])^n, x], x] /; FreeQ[{a, b, c, d}, x] &&
 IntegerQ[m] && IGtQ[n, 0]

Rule 3171

Int[cos[(c_.) + (d_.)*(x_)]^(m_.)*(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(n_), x_Symb
ol] :> Dist[a^n*b^n, Int[Cos[c + d*x]^m/(b*Cos[c + d*x] + a*Sin[c + d*x])^n, x], x] /; FreeQ[{a, b, c, d, m},
x] && EqQ[a^2 + b^2, 0] && ILtQ[n, 0]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps \begin{align*} \text {integral}& = -\frac {i \int \sec ^2(c+d x) (i a \cos (c+d x)+a \sin (c+d x)) \, dx}{a^2} \\ & = -\frac {i \int (i a \sec (c+d x)+a \sec (c+d x) \tan (c+d x)) \, dx}{a^2} \\ & = -\frac {i \int \sec (c+d x) \tan (c+d x) \, dx}{a}+\frac {\int \sec (c+d x) \, dx}{a} \\ & = \frac {\text {arctanh}(\sin (c+d x))}{a d}-\frac {i \text {Subst}(\int 1 \, dx,x,\sec (c+d x))}{a d} \\ & = \frac {\text {arctanh}(\sin (c+d x))}{a d}-\frac {i \sec (c+d x)}{a d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.40 (sec) , antiderivative size = 35, normalized size of antiderivative = 1.13 \[ \int \frac {\sec ^2(c+d x)}{a \cos (c+d x)+i a \sin (c+d x)} \, dx=-\frac {i \left (2 i \text {arctanh}\left (\sin (c)+\cos (c) \tan \left (\frac {d x}{2}\right )\right )+\sec (c+d x)\right )}{a d} \]

[In]

Integrate[Sec[c + d*x]^2/(a*Cos[c + d*x] + I*a*Sin[c + d*x]),x]

[Out]

((-I)*((2*I)*ArcTanh[Sin[c] + Cos[c]*Tan[(d*x)/2]] + Sec[c + d*x]))/(a*d)

Maple [B] (verified)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 64 vs. \(2 (30 ) = 60\).

Time = 0.59 (sec) , antiderivative size = 65, normalized size of antiderivative = 2.10

method result size
norman \(\frac {2 i}{a d \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-1\right )}+\frac {\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{a d}-\frac {\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{a d}\) \(65\)
derivativedivides \(\frac {\frac {2 i}{2 \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-2}-\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )-\frac {i}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1}+\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{a d}\) \(70\)
default \(\frac {\frac {2 i}{2 \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-2}-\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )-\frac {i}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1}+\ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{a d}\) \(70\)
risch \(-\frac {2 i {\mathrm e}^{i \left (d x +c \right )}}{d a \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}+\frac {\ln \left (i+{\mathrm e}^{i \left (d x +c \right )}\right )}{a d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{a d}\) \(74\)

[In]

int(sec(d*x+c)^2/(cos(d*x+c)*a+I*a*sin(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

2*I/a/d/(tan(1/2*d*x+1/2*c)^2-1)+1/a/d*ln(tan(1/2*d*x+1/2*c)+1)-1/a/d*ln(tan(1/2*d*x+1/2*c)-1)

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 80 vs. \(2 (29) = 58\).

Time = 0.24 (sec) , antiderivative size = 80, normalized size of antiderivative = 2.58 \[ \int \frac {\sec ^2(c+d x)}{a \cos (c+d x)+i a \sin (c+d x)} \, dx=\frac {{\left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right )} \log \left (e^{\left (i \, d x + i \, c\right )} + i\right ) - {\left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right )} \log \left (e^{\left (i \, d x + i \, c\right )} - i\right ) - 2 i \, e^{\left (i \, d x + i \, c\right )}}{a d e^{\left (2 i \, d x + 2 i \, c\right )} + a d} \]

[In]

integrate(sec(d*x+c)^2/(a*cos(d*x+c)+I*a*sin(d*x+c)),x, algorithm="fricas")

[Out]

((e^(2*I*d*x + 2*I*c) + 1)*log(e^(I*d*x + I*c) + I) - (e^(2*I*d*x + 2*I*c) + 1)*log(e^(I*d*x + I*c) - I) - 2*I
*e^(I*d*x + I*c))/(a*d*e^(2*I*d*x + 2*I*c) + a*d)

Sympy [F]

\[ \int \frac {\sec ^2(c+d x)}{a \cos (c+d x)+i a \sin (c+d x)} \, dx=\frac {\int \frac {\sec ^{2}{\left (c + d x \right )}}{i \sin {\left (c + d x \right )} + \cos {\left (c + d x \right )}}\, dx}{a} \]

[In]

integrate(sec(d*x+c)**2/(a*cos(d*x+c)+I*a*sin(d*x+c)),x)

[Out]

Integral(sec(c + d*x)**2/(I*sin(c + d*x) + cos(c + d*x)), x)/a

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 83 vs. \(2 (29) = 58\).

Time = 0.22 (sec) , antiderivative size = 83, normalized size of antiderivative = 2.68 \[ \int \frac {\sec ^2(c+d x)}{a \cos (c+d x)+i a \sin (c+d x)} \, dx=\frac {\frac {\log \left (\frac {\sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} + 1\right )}{a} - \frac {\log \left (\frac {\sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} - 1\right )}{a} - \frac {2}{-i \, a + \frac {i \, a \sin \left (d x + c\right )^{2}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{2}}}}{d} \]

[In]

integrate(sec(d*x+c)^2/(a*cos(d*x+c)+I*a*sin(d*x+c)),x, algorithm="maxima")

[Out]

(log(sin(d*x + c)/(cos(d*x + c) + 1) + 1)/a - log(sin(d*x + c)/(cos(d*x + c) + 1) - 1)/a - 2/(-I*a + I*a*sin(d
*x + c)^2/(cos(d*x + c) + 1)^2))/d

Giac [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 58, normalized size of antiderivative = 1.87 \[ \int \frac {\sec ^2(c+d x)}{a \cos (c+d x)+i a \sin (c+d x)} \, dx=\frac {\frac {\log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1\right )}{a} - \frac {\log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1\right )}{a} + \frac {2 i}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )} a}}{d} \]

[In]

integrate(sec(d*x+c)^2/(a*cos(d*x+c)+I*a*sin(d*x+c)),x, algorithm="giac")

[Out]

(log(tan(1/2*d*x + 1/2*c) + 1)/a - log(tan(1/2*d*x + 1/2*c) - 1)/a + 2*I/((tan(1/2*d*x + 1/2*c)^2 - 1)*a))/d

Mupad [B] (verification not implemented)

Time = 23.16 (sec) , antiderivative size = 43, normalized size of antiderivative = 1.39 \[ \int \frac {\sec ^2(c+d x)}{a \cos (c+d x)+i a \sin (c+d x)} \, dx=\frac {2\,\mathrm {atanh}\left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )}{a\,d}+\frac {2{}\mathrm {i}}{a\,d\,\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2-1\right )} \]

[In]

int(1/(cos(c + d*x)^2*(a*cos(c + d*x) + a*sin(c + d*x)*1i)),x)

[Out]

(2*atanh(tan(c/2 + (d*x)/2)))/(a*d) + 2i/(a*d*(tan(c/2 + (d*x)/2)^2 - 1))